package com.admission.listener;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.admission.model.CollegeNotice;
import com.admission.service.CollegeNoticeManager;
import com.admission.util.CollegeDetailTips;
import com.admission.util.StaticEnroll;
import com.admission.util.StaticIndex;
import com.admission.util.StaticRecruitment;

//@Repository
public class IndexListener implements InitializingBean {

	private StaticIndex staticIndex;
	private StaticEnroll staticEnroll;
	private StaticRecruitment staticRecruitment;
	private CollegeNoticeManager collegeNoticeManager;

	public void afterPropertiesSet() throws Exception {

		try {

			staticIndex.createHtmlForMainPage();
			staticEnroll.createHtmlForEnrollDetail();
			staticRecruitment.createHtmlForRecruitmentDetail();
			CollegeNotice c = collegeNoticeManager
					.getByType(CollegeNotice.COLLEGETYPE);
			if (c != null) {
				CollegeDetailTips.setNoticeTipes(c.getContent(), c.getType());
				CollegeDetailTips.setSpecialTips(c.getNote(), c.getType());
			}
			c = collegeNoticeManager.getByType(CollegeNotice.ARTTYPE);
			if (c != null) {
				CollegeDetailTips.setNoticeTipes(c.getContent(), c.getType());
				CollegeDetailTips.setSpecialTips(c.getNote(), c.getType());
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Autowired
	public void setStaticIndex(StaticIndex staticIndex) {
		this.staticIndex = staticIndex;
	}

	@Autowired
	public void setStaticEnroll(StaticEnroll staticEnroll) {
		this.staticEnroll = staticEnroll;
	}

	@Autowired
	public void setStaticRecruitment(StaticRecruitment staticRecruitment) {
		this.staticRecruitment = staticRecruitment;
	}

	@Autowired
	public void setCollegeNoticeManager(
			CollegeNoticeManager collegeNoticeManager) {
		this.collegeNoticeManager = collegeNoticeManager;
	}

}
